package com.himilco.ocana.gui.admin;

import com.himilco.ocana.workflow.core.dao.entities.Ticket;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.primefaces.event.map.OverlaySelectEvent;
import org.primefaces.model.map.DefaultMapModel;
import org.primefaces.model.map.LatLng;
import org.primefaces.model.map.MapModel;
import org.primefaces.model.map.Marker;

public class AdminIncidentViewerModel {

    private List<IncidentEvent> incidentsList = new ArrayList<IncidentEvent>();
    private Ticket selectedTicket = new Ticket();
    private Map map = new Map();
    private List<Ticket> tickets = new ArrayList<Ticket>();

    public List<IncidentEvent> getIncidentsList() {
        return incidentsList;
    }

    public void setIncidentsList(List<IncidentEvent> incidentsList) {
        this.incidentsList = incidentsList;
    }

    public List<Ticket> getTickets() {
        return tickets;
    }

    public void setTickets(List<Ticket> tickets) {
        this.tickets = tickets;
    }

    public void setMap(Map map) {
        this.map = map;
    }

    public Map getMap() {
        return map;
    }

    public Ticket getSelectedTicket() {
        return selectedTicket;
    }

    public void setSelectedTicket(Ticket selectedTicket) {
        this.selectedTicket = selectedTicket;
    }

    public class Map implements Serializable {

        private MapModel advancedModel;
        private Marker marker;

        public Map() {
            advancedModel = new DefaultMapModel();

            // Shared coordinates
            LatLng coord1 = new LatLng(36.879466, 30.667648);
            LatLng coord2 = new LatLng(36.883707, 30.689216);
            LatLng coord3 = new LatLng(36.879703, 30.706707);
            LatLng coord4 = new LatLng(36.885233, 30.702323);

//			LatLng coord5 = new LatLng(36.889852,30.682181); 

            // Icons and Data
            advancedModel.addOverlay(new Marker(coord1, "Habib Bouguiba",new Object(),"atm-down.jpg"));
            
            advancedModel.addOverlay(new Marker(coord2, "Manouba"));
            advancedModel.addOverlay(new Marker(coord4, "Tathamen"));
            advancedModel.addOverlay(new Marker(coord3, "Gazella"));
//			advancedModel.addOverlay(new Marker(coord5,"toto"));   

            IncidentEvent ie = new IncidentEvent();
            ie.setIncident_subject("CASH ERROR");
            List<IncidentEvent> listincidents = new ArrayList<IncidentEvent>();
            listincidents.add(ie);
            System.out.println("size list :" + listincidents.size());

            Iterator itr = listincidents.iterator();
            while (itr.hasNext()) {
                ie = (IncidentEvent) itr.next();
                LatLng coord5 = new LatLng(36.889852, 30.682181);
//				advancedModel.addOverlay(new Marker(coord5,elem.getIncident_subject()));
                advancedModel.addOverlay(new Marker(coord5, "toto"));
            }
        }

        public void onMarkerSelect(OverlaySelectEvent event) {
            marker = (Marker) event.getOverlay();
        }

        public MapModel getAdvancedModel() {
            return advancedModel;
        }

        public Marker getMarker() {
            return marker;
        }
    }
}
